import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import AutoImport from 'unplugin-auto-import/vite'
import components from 'unplugin-vue-components/vite'

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      imports: ['vue','vue-router',],
      dirs: ['src/api'],
      dts: 'src/auto-import.d.ts'
    }),
    //自动导入组件
    components({
      dirs: ['src/components'], //指定组件目录
      extensions: ['vue'],  //指定组件拓展名
      //dts: 'src/components.d.ts',
      deep: true,  //是否深度扫描
    })
  ],
  server:{
    host:'0.0.0.0',//允许访问的主机头
    port: 5000, //端口号
    proxy: {
      '/api': {
        target: 'http://localhost:8080',
        changeOrigin: true,
      }
    },
  },
  
  resolve:{
    alias:{
      '@':path.resolve(__dirname,'./src'),
    }
  }
})
